<style>
.order-pay-dialog-c .alert-info {
	/**background: url("/Public/Images/icon_alert.gif") no-repeat scroll 0 0 transparent;**/
	font-family: '黑体', arial, sans-serif;
	font-size: 16px;
	height: 56px;
	/**margin: 30px 35px;
										    padding-left: 80px;**/
	padding: 30px 0 30px 20px;
}

.order-pay-dialog-c .notice {
	line-height: 20px;
	padding: 3px 30px;
}

.order-pay-dialog-c .act {
	margin: 15px 35px 20px;
	text-align: center;
}

.order-pay-dialog-c .retry {
	margin: 20px 35px 20px;
}

.order-pay-dialog-c .formbutton {
	background: none repeat scroll 0 0 #63C5C8;
	border-color: #82D0D4 #4D989B #54A3A7 #92D6D9;
	border-style: solid;
	border-width: 2px;
	color: #FFFFFF;
	cursor: pointer;
	letter-spacing: 0.1em;
	padding: 4px 1em;
}
</style>

<php>
/**
	$pb_paymentData=array(	'itemType'=>'pay_order'//支付类型，订单支付'pay_order'或账户冲值'pay_charge'
							,'itemId'=>''//对应订单支付'order'或账户冲值'charge'支付的对象id
							,'payAmount'=>''//需支付的现金总数，现金帐户支付时使用
							,'payType'=>''//选择的支付类型
							//,'jsfun_onClickDoPay'=>''//支付成功后执行的js函数,该函数有一个参数itemId
							,'jsfun_afterPaySuccess'=>''//支付成功后执行的js函数,该函数有一个参数itemId
							,'jsfun_afterPayFailed'=>''//支付失败后执行的js函数,该函数有一个参数itemId
						);
**/
//dump($pb_paymentData);

//屏蔽掉冲值
$pb_paymentData['itemType']='pay_order';
</php>
<script type="text/javascript">
	<php>if(!empty($pb_paymentData['payType'])){</php>
	$(document).ready(function(){
		doPay();
	});
	<php>}</php>
	/** 显示付款探出框 **/
	function doPay() {
		var paytype_ = getselectpaymode();
		
		if (paytype_ == '') {
			k_alert('请选择支付类型', '现金支付');
			return;
		}
		
		if(paytype_ == 'xxypay'){
			k_loading('数据处理中，请稍候...', '现金支付');
			doCashPay();
			return;
		}
		ui.box.close();
		//k_alert($('#pop_show_payment_doing').html(),'提示');
		ui.box.show($('#pop_show_payment_doing').html(), {
			title : '现金支付'
		});
		
		gotoPaymentPage();
	}

	function doCashPay(){
		var payAmount = '{$pb_paymentData['payAmount']}';
		$.kajax({      
    		ajx_rtn_type:'JSON',
			url:"{:U('User://Account/ajxRefreshCash')}",      
			type:'post', //数据发送方式  
			//data:{pno:pno,atype:$('#ajx_show_area_detail').find('#atype').val()} ,    
			async: false ,//同步方式     
			success: function(jsonData){ 
				//alert(jsonData);
				//k_success("账户余额刷新完成！账户余额："+(jsonData.data.current_money*1)+" 需支付金额："+(payAmount*1));
				if((jsonData.data.current_money*100)>=(payAmount*100)){
					$('#pop_show_xxypay_payment').find('#xxypay_payment_account_money').html(jsonData.data.current_money_format);
					ui.box.close();
					//k_alert($('#pop_show_payment_doing').html(),'提示');
					ui.box.show($('#pop_show_xxypay_payment').html(), {
						title : '现金支付'
					});
				}else{
					k_error('账户余额不足，请充值后再试！');
				}
			}
		});
	}

	
	function paySuccess() {
		k_loading('数据处理中，请稍候...', '现金支付');
		//alert($("#gotopayment").find("#itemType").val()+"  "+ $("#gotopayment").find("#itemId").val());
		$.kajax({	ajx_rtn_type : 'JSON',
					url : "{:U('Index://Pay/paySuccess')}",
					type : 'post', //数据发送方式  
					data : {	itemType:$("#gotopayment").find("#itemType").val()
								,itemId : $("#gotopayment").find("#itemId").val()
					},
					//dataType:'xml', //接受数据格式      
					error : function(json) {
					},
					async : false,//同步方式     
					success : function(obj) {
						ui.box.close();
						if (obj.status == 1) {
							<php>if(!empty($pb_paymentData['jsfun_afterPaySuccess'])){</php>
								{$pb_paymentData['jsfun_afterPaySuccess']}($("#gotopayment").find("#itemId").val());
							<php>}else{</php>
								k_success(obj.msg);
							<php>}</php>
						} else {
							<php>if(!empty($pb_paymentData['jsfun_afterPayFailed'])){</php>
								{$pb_paymentData['jsfun_afterPayFailed']}($("#gotopayment").find("#itemId").val());
							<php>}else{</php>
								k_alert(obj.msg, '现金支付');
							<php>}</php>
						}
					}
				});
	}
	
	function payFail(){
		//alert('付款遇到问题，点击执行payFail()');
	}
	
	function getselectpaymode(){
		var paytype_ = "";
		$("#paytypeselect").find("#payType").each(function() {
			if ($(this).attr("checked") == true) {
				paytype_ = $(this).attr("value");
			}
		});
		return paytype_;
	}
	/**打开支付界面**/
	function gotoPaymentPage(){
		var paytype_ = getselectpaymode();
		$("#gotopayment").find("#selectedPayType").val(paytype_);
		
		//如果为现金帐户充值
		<php>if($pb_paymentData['itemType']=='pay_charge'){</php>
		var camount = $("#charge_amount").val();
		$("#gotopayment").find("#camount").val(camount);
		if(camount==0){
			ui.box.close();
			k_alert('请录入充值金额！');
			return;
		}
		<php>}</php>
		$("#gotopayment").submit();
	}
	
</script>


<form target="_blank" method="post" action="{:U('Index://Pay/gotoPayment')}" id="gotopayment">
	<input id="itemType" name="itemType" value="{$pb_paymentData['itemType']}" type="hidden">
	<input id="itemId" name="itemId" value="{$pb_paymentData['itemId']}" type="hidden">
	<input id="camount" name="camount" value="" type="hidden">
	<input id="selectedPayType" name="selectedPayType" value="{$pb_paymentData['payType']}" type="hidden">
</form>
<div id="paytypeselect" style="text-align: left; padding: 0px;">
	<ul class="paytype-list " id="order-check-typelist">
		<php>
		//屏蔽掉现金帐户 if($pb_paymentData['itemType']!='pay_charge'){
		if(false){</php>
		<!-- 如果不为现金帐户充值，则可以使用现金帐户支付 -->
		<li class="item">
			<div class="bank" style="width:100%">
			<input type="radio"<php>if($pb_paymentData['payType']=='xxypay'){</php>checked<php>}</php>
				value="xxypay" name="payType" id="payType" class="input" >
			<img src="/Public/Images/global/xxypay_icon.gif" style="margin-top:3px;">
			<label class="label" style="margin-top:10px;margin-left:10px;">选择现金帐户支付，若余额不足，
				点击进行 <a target="_blank" href="{:U('User://Account/cash',array('atype'=>'charge'))}" style="color:red">账户充值</a> ！
			</label>
			</div>	
		</li>
		<php>}</php>
		<li class="item">
			<div class="bank" style="width:100%">
			<input type="radio"<php>if($pb_paymentData['payType']=='tenpay'){</php>checked<php>}</php>
				value="tenpay" name="payType" id="payType" class="input" >
			<img src="/Public/Images/global/tenpay_icon.gif" style="margin-top:3px;">
			<label class="label" style="margin-top:10px;margin-left:20px;">无需注册，支持国内各大银行支付</label>
			</div>
		</li>
		<li class="item">
			<div class="bank" style="width:100%">
			<input type="radio"<php>if($pb_paymentData['payType']=='alipay'){</php>checked<php>}</php>
				value="alipay" name="payType" id="payType" class="input" >
			<img src="/Public/Images/global/alipay_icon.gif" style="margin-top:3px;">
			<label class="label" style="margin-top:10px;margin-left:20px;">推荐淘宝用户使用</label>
			</div>
		</li>
		
		<li class="item">
			<php>
				$tmp_ary_paymentconfig = (include K_CONFIG_PATH.'config_payment.php');
				//dump($tmp_ary_paymentconfig);
				$tmp_index = 0;
				foreach($tmp_ary_paymentconfig['pay_bank'] as $payconf){
					if(in_array($payconf['code'],array('xxypay','alipay','tenpay')))continue;
					</php>
						<div class="bank">
						<input type="radio"<php>if($payconf['code']==$pb_paymentData['payType']){</php>checked<php>}</php>
										value="{$payconf['code']}" name="payType" id="payType" class="input" >
								<img src="{$payconf['icon']}">
						</div>
					<php>
					$tmp_index = $tmp_index+1;
					if($tmp_index%4==0){
					</php>
						</li><li class="item">
					<php>}
				}
			</php>
		</li>
		
	</ul>
	<div class="clear"></div>
	<div class="step" style="text-align: right; margin: 0px;">
		<input	id="goPay" class="btn_rl" type="button" onclick="paySuccess();" value="已付款？点击此处" />
		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		<input	id="goPay" class="btn_r" type="button" onclick="doPay();"	value=" 付款 >>" />
	
		<div id="pop_show_payment_doing" class="hidden">
			<div class="order-pay-dialog-c">
				<p class="alert-info"><img src="/Public/Images/message_alert.png">&nbsp;&nbsp;请您在新打开的页面上完成付款。&nbsp;&nbsp;</p>
				<p class="notice">
					付款完成前请不要关闭此窗口。 <br>
					完成付款后请根据您的情况点击下面的按钮：
				</p>
				<p class="act">
					<input type="button" value="已完成付款" class="btn_rl" onclick="paySuccess();">
					&nbsp;&nbsp;&nbsp;&nbsp;
					<input type="button" value="付款遇到问题" class="btn_rl" onclick="payFail();">
				</p>
				<p class="retry">
					<a class="back" id="order-pay-dialog-back" href="javascript:ui.box.close();">» 返回选择其他支付方式</a>
				</p>
			</div>
		</div>
		<div id="pop_show_xxypay_payment" class="hidden">
			<div class="order-pay-dialog-c">
				<p class="alert-info"><img src="/Public/Images/message_alert.png">&nbsp;&nbsp;确认用现金帐户付款么？&nbsp;&nbsp;</p>
				<p class="notice">
					账户余额：<font id="xxypay_payment_account_money" style="color:red"></font>
					&nbsp;&nbsp;&nbsp;&nbsp;
					支付金额：<font style="color:red">{$pb_paymentData['payAmount']}&nbsp;元</font><br>
					将从现金帐户扣除&nbsp;<font style="color:red">{$pb_paymentData['payAmount']}&nbsp;元</font>
				</p>
				<p class="act">
					<input type="button" value="确认付款" class="btn_rl" 
							onclick="	ui.box.close();
										ui.box.show($('#pop_show_payment_doing').html(), {
											title : '现金支付'
										});
										gotoPaymentPage();
					">
				</p>
				<p class="retry">
					<a class="back" id="order-pay-dialog-back" href="javascript:ui.box.close();">» 返回选择其他支付方式</a>
				</p>
			</div>
		</div>
	</div>
</div>